/**
 * 
 */
package probe;

import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;

import probe.gui.MainWindowController;

/**
 * @author Linus
 * 
 */
enum GUI_STATE
{
	NORMAL,
	CALENDAR
}
public class Gui {
	
	
	public static StyleContext styleContext;
	public static Style NORMAL;
	public static Style COMMAND;
	public static Style SUB_COMMAND;
	public static final int NORMAL_FONT_SIZE = 14;
	public static final int COMMAND_FONT_SIZE = 18;
	public static final int SUB_COMMAND_FONT_SIZE = 16;
	public static final Color NORMAL_FONT_COLOR = Color.BLACK;
	public static final Color COMMAND_FONT_COLOR = Color.RED;
	public static final Color SUB_COMMAND_FONT_COLOR = Color.MAGENTA;
	
	public static final GUI_STATE _gui_state=GUI_STATE.NORMAL;
	
	private static MainWindowController _mainWindowController;

	public Root _root;

	public void init(Root root) {

	
		_root = root;
		initStyles();

		_mainWindowController = new MainWindowController(this);

		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					_mainWindowController.init();

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	public void initStyles() {
		styleContext = new StyleContext();
		NORMAL = styleContext.addStyle("NORMAL",
				styleContext.getStyle(StyleContext.DEFAULT_STYLE));
		COMMAND = styleContext.addStyle("COMMAND",
				styleContext.getStyle(StyleContext.DEFAULT_STYLE));
		SUB_COMMAND = styleContext.addStyle("SUB_COMMAND",
				styleContext.getStyle(StyleContext.DEFAULT_STYLE));

		StyleConstants.setForeground(NORMAL, NORMAL_FONT_COLOR);
		StyleConstants.setForeground(COMMAND, COMMAND_FONT_COLOR);
		StyleConstants.setForeground(SUB_COMMAND, SUB_COMMAND_FONT_COLOR);
		StyleConstants.setFontSize(NORMAL, NORMAL_FONT_SIZE);
		StyleConstants.setFontSize(COMMAND, COMMAND_FONT_SIZE);
		StyleConstants.setFontSize(SUB_COMMAND, SUB_COMMAND_FONT_SIZE);
		
		
	}
	public static void printOutput(final Style style,final String printfIdentifier,final Object ... args)
	{
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				if (_gui_state == GUI_STATE.NORMAL) {
					_mainWindowController.printUserInputToOutput(style,
							printfIdentifier, args);
				}

			}
		});
		
	}

}
